<template>
  <div class="left-menu">
    <div class="menu">
      <router-link
        :to="item.url"
        v-for="(item,i) in props.menus"
        :key="i"
        class="item"
        :class="selectItem.title === item.title ? 'selectItem' : ''"
        @click="selectPage(item)"
      >{{ item.title }}</router-link>
    </div>
  </div>
</template>

<script setup lang="ts">
export interface Menu {
  title: string,
  url: string
}
import { defineProps, PropType, reactive } from 'vue'
const props = defineProps({
  menus: {
    type: Array as PropType<Menu[]>,
    required: false,
    default: () => {
      return [{ title: '实时报警', url: '/' }]
    }
  }
})
let selectItem: Menu = reactive({ title: '实时报警', url: '/' })
const selectPage = (item: Menu) => {
  selectItem.title = item.title
  selectItem.url = item.url
}
</script>
<style lang="scss" scoped>
.left-menu {
  width: 100%;
  height: 100%;
  background: #ffffff;

  .menu {
    height: 100%;
    justify-content: flex-start;
    .item {
      display: block;
      padding: 14px 0 14px 20px;
      font-size: 16px;
      font-weight: 400;
      line-height: 24px;
      font-family: Source Han Sans CN;
      color: #666666;
      cursor: pointer;
    }
    .item:hover {
      color: #498ff0;
    }
    .selectItem {
      color: #498ff0;
    }
  }
}
</style>
